package com.myidis.servlet;

import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.myidis.entity.RightRole;
import com.myidis.mapper.RightRoleMapper;

@Service
public class RightRoleServlet {
	@Autowired
	private RightRoleMapper rightRoleMapper;
	
	public List<RightRole> all() {
		return rightRoleMapper.all();
	}
	
	public RightRole getOne(int id) {
		return rightRoleMapper.getOne(id);
	}
	
	public boolean check(RightRole obj) {
		return rightRoleMapper.getByName(obj) == null? true: false;
	}
	
	public int insert(RightRole obj) {
		return rightRoleMapper.insert(obj);
	}
	
	public int insertAll(List<RightRole> objs) {
		int count = 0;
		for (RightRole obj: objs) {
			System.out.println(obj.toString());
			count += rightRoleMapper.insert(obj);
		}
		return count;
	}
	
	public int update(RightRole obj) {
		return rightRoleMapper.update(obj);
	}
	
	public int delete(int id) {
		return rightRoleMapper.delete(id);
	}
	
	public int deleteAll(int[] ids) {
		int count = 0;
		for(int id: ids)
			count += rightRoleMapper.delete(id);
		return count;
	}
}
